package com.list;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TestList {


    public static void main(String[] args) {

        List<String> list = new ArrayList<String>();
        list.add("java");
        list.add("java");
        list.add("java");

        //遍历输出
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("---------------");

        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("---------------");

        for(String s : list){
            System.out.println(s);
        }
        System.out.println("---------------");

        //jdk1.8后 lambda
        list.forEach(s -> System.out.println(s));
        System.out.println("---------------");


        list.forEach(s ->{
            System.out.println(s);
        });



    }

}
